package news.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whu.administrator.ws.MyApplication;
import com.whu.administrator.ws.R;

import java.util.ArrayList;
import java.util.List;

import model.BeiWang;
import news.dto.SimpleNotify;

/**
 * 通知
 * Created by Administrator on 2016/3/23.
 */
public class SimpleNotifyAdapter extends BaseAdapter {

    List<SimpleNotify> simpleNotifies = new ArrayList<SimpleNotify>();

    public void setSimpleNotifies(List<SimpleNotify> simpleNotifies) {
        this.simpleNotifies = simpleNotifies;
    }

    @Override
    public int getCount() {
        return simpleNotifies.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(MyApplication.share(), R.layout.item_simplenotify, null);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.id_tv_time);
            viewHolder.tv_author = (TextView) convertView.findViewById(R.id.id_tv_author);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.id_tv_title);
            viewHolder.tv_degist = (TextView) convertView.findViewById(R.id.id_tv_Digest);

            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        SimpleNotify simpleNotify = simpleNotifies.get(position);
        viewHolder.tv_time.setText(simpleNotify.getNotify_Time());
        viewHolder.tv_title.setText(simpleNotify.getNotify_Title());
        viewHolder.tv_author.setText(simpleNotify.getNotify_Author());
        viewHolder.tv_degist.setText(simpleNotify.getNotify_Digest());
        return convertView;
    }


    public static class ViewHolder {
        public TextView tv_time;
        public TextView tv_author;
        public TextView tv_title;
        public TextView tv_degist;
    }
}
